import 'package:flutter/material.dart';
import 'package:flutter_demo/pages/page_with_title.dart';

import '../../../widgets/app_widgets.dart';

class PaddingPage extends PageWithTitle {
  const PaddingPage() : super("边距组件(Padding)");

  @override
  List<Widget> buildContentWidgets(BuildContext context) {
    return const [
      PrimaryTitle("简介"),
      BodyText("边距组件用于嵌套在目标组件上设置边距，在目标组件外嵌套表现为外边距，目标组件内嵌套表现为内边距"),
      AppSpacer.large,
      _Example(),
      UlItem("Padding"),
      LabelText("- padding 设置边距值")
    ];
  }
}

class _Example extends StatelessWidget {
  const _Example();

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        ColoredBox(
          color: Colors.red,
          child: Padding(
            padding: const EdgeInsetsDirectional.all(10),
            child: Container(
              width: 100,
              height: 100,
              color: Colors.green,
              child: const Padding(
                padding: EdgeInsetsDirectional.all(10),
                child: ColoredBox(color: Colors.blue),
              ),
            ),
          ),
        )
      ],
    );
  }
}
